<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <style>
      div{
        border: 1px solid black;
      }
    </style>
    <title></title>
  </head>
  <body>
    <div id="app">
      <router-link to="/">去首页</router-link>
      <router-link to="/login">去登录页</router-link>
      <router-link to="/content/1001">去内容1</router-link>
      <router-link to="/content/1002">去内容2</router-link>
      <router-view></router-view>
    </div>
    <script src="./vue.js"></script>
    <script src="./vue-router.min.js"></script>
    <script>
      const routes = [
        {
          path: "/",
          component: {
            template: `<div>首页
            <br/>
            <router-link to="/a1">子路由1</router-link>
            <router-link to="/a2">子路由2</router-link>
             <router-view></router-view>
             </div>`,
          },
          children: [
            { path: "/a1", component:{template: "<div>子组件1</div>" }},
            { path: "/a2", component:{template: "<div>子组件2</div>" }},
          ],
        },
        {
          path: "/login",
          component: { template: "<div>登录页</div>" },
        },
         
        {
          path: "/content/:id",
          component: { template: "<div>内容{{$route.params.id}}</div>" },
        },
      ];
      const router = new VueRouter({ routes });

      const vm = new Vue({
        el: "#app",
        data: {},
        methods: {},
        router,
      });
       
    </script>
  </body>
</html>
